home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 September (IDG) / Sep99.iso / Shareware World / Utilities / Text Processing / Alpha / Tcl / Modes / latex Mode / latexMenu.tcl < prev    next >
Encoding:
Text File  |  1999-05-17  |  38.0 KB  |  1,601 lines  |  [TEXT/ALFA]

  1. #############################################################################
  2. #############################################################################
  3. #
  4. # latexMenu.tcl (called from latex.tcl)
  5. #
  6. # LaTeX menu definitions and key bindings
  7. #
  8. #############################################################################
  9. #
  10. # Author:  Tom Scavo <trscavo@syr.edu>, Vince Darley <darley@fas.harvard.edu>
  11. #
  12. #############################################################################
  13. #############################################################################
  14.  
  15. proc latexMenu.tcl {} {}
  16.  
  17. namespace eval TeX::sub {}
  18. namespace eval TeX::mp {}
  19.  
  20. # The highest level menu macro, to be called initially or whenever 
  21. # the LaTeX menu must be rebuilt (as in 'shadowtexSig' in latex.tcl,
  22. # or 'toggleLaTeXMenus' below): (simplified VMD July 97)
  23. proc buildLaTeXMenuQuietly {} {
  24.     global texMenu useShortLaTeXMenu useAMSLaTeX TeX::Menus
  25.     toggleAMSLaTeXmenus
  26.     TeX::sub::MathModes
  27.     
  28.     menu::buildProc texMenu buildLaTeXMenu
  29.     menu::buildSome texMenu
  30.     markMenuItem {LaTeX Utilities} {Short LaTeX Menu} $useShortLaTeXMenu
  31.     markMenuItem {LaTeX Utilities} {AMS-LaTeX} $useAMSLaTeX
  32. }
  33.  
  34. # Toggle the short menu flag and rebuild the LaTeX menu.  If the
  35. # latter operation fails, toggle the flag back to its original position.
  36. proc toggleLaTeXMenus {} {
  37.     toggleLaTeXMenuItem useShortLaTeXMenu
  38.     buildLaTeXMenuQuietly
  39. }
  40. # Toggle the AMS-LaTeX flag, reload the macros and menu, and rebuild 
  41. # the LaTeX menu.  If either of the latter two operations fail, toggle
  42. # the flag back to its original position.
  43. proc toggleAMSLaTeX {} {
  44.     global useAMSLaTeX
  45.     toggleLaTeXMenuItem useAMSLaTeX
  46.     toggleAMSLaTeXmenus
  47.     markMenuItem {LaTeX Utilities} {AMS-LaTeX} $useAMSLaTeX
  48.     menu::buildSome "Math Style" "Text Size" "Math Environments"
  49. }
  50.  
  51. proc toggleLaTeXMenuItem {flag} {
  52.     global $flag modifiedVars
  53.     set $flag [expr 1 - [set $flag]]
  54.     lappend modifiedVars $flag
  55. }
  56.  
  57. proc listToDummySubmenus {l} {
  58.     foreach i $l {
  59.     lappend ret [list Menu -n $i {}]
  60.     }
  61.     return $ret
  62. }
  63.  
  64. # Return a short menu or a long menu, depending on the value of
  65. # the global variable 'useShortLaTeXMenu':
  66. proc buildLaTeXMenu {} {
  67.     global useShortLaTeXMenu TeX::Menus texMenu
  68.     if {$useShortLaTeXMenu} {
  69.     return [list build [concat \
  70.       [listToDummySubmenus [set TeX::Menus(Top)]] \
  71.       [list "LaTeX Help"] \
  72.       {(-} \
  73.       [listToDummySubmenus [set TeX::Menus(Bottom)]] \
  74.       [listToDummySubmenus [list "Text Submenus" "Math Submenus"]] \
  75.       ] \
  76.       {TeX::mp::latex -M TeX -m} \
  77.       [concat [set TeX::Menus(Top)] [set TeX::Menus(Bottom)] \
  78.       [list "Text Submenus" "Math Submenus"]] \
  79.       $texMenu]
  80.     } else {
  81.     return [list build [concat \
  82.       [listToDummySubmenus [set TeX::Menus(Top)]] \
  83.       [list "LaTeX Help"] \
  84.       {(-} \
  85.       [listToDummySubmenus [set TeX::Menus(Bottom)]] \
  86.       {(-} \
  87.       [listToDummySubmenus [set TeX::Menus(TextSubMenus)]] \
  88.       {(-} \
  89.       [listToDummySubmenus [set TeX::Menus(MathSubMenus)]] \
  90.       ] \
  91.       {TeX::mp::latex -M TeX -m} \
  92.       [concat [set TeX::Menus(Top)] [set TeX::Menus(Bottom)] \
  93.       [set TeX::Menus(TextSubMenus)] [set TeX::Menus(MathSubMenus)]] \
  94.       $texMenu]
  95.     }
  96. menu::buildProc "Math Submenus" TeX::sub::Math
  97. menu::buildProc "Text Submenus" TeX::sub::Text
  98. menu::buildProc Process TeX::sub::Process
  99. menu::buildProc ProcessOpen TeX::sub::ProcessOpen
  100. proc TeX::sub::Math {} {
  101.     global TeX::Menus
  102.     return [list build \
  103.       [listToDummySubmenus [set TeX::Menus(MathSubMenus)]] \
  104.       {dummy -M TeX -m} \
  105.       [set TeX::Menus(MathSubMenus)] \
  106.       {Math Submenus}]
  107. }
  108. proc TeX::sub::Text {} {
  109.     global TeX::Menus
  110.     return [list build \
  111.       [listToDummySubmenus [set TeX::Menus(TextSubMenus)]] \
  112.       {dummy -M TeX -m} \
  113.       [set TeX::Menus(TextSubMenus)] \
  114.       {Text Submenus}]
  115. }
  116.  
  117. ensureset TeX::Menus(TextSubMenus) [list \
  118.   "Text Style" "Text Size" "Text Commands" "International" \
  119.   "Environments" "Boxes" "Miscellaneous"\
  120.   ]
  121.  
  122. ensureset TeX::Menus(Top) [list "Process" "Goto" "LaTeX Utilities"]
  123.  
  124. ensureset TeX::Menus(Bottom) [list "Documents" "Page Layout" \
  125.   "Sectioning" "Theorem"]
  126.  
  127. ensureset TeX::Menus(MathSubMenus) [list \
  128.   "Math Modes" "Math Style" "Math Environments" "Formulas" "Greek"  \
  129.   "Binary Operators" "Relations" "Arrows" "Dots" "Symbols" \
  130.   "Functions" "Large Operators" "Delimiters" "Math Accents" \
  131.   "Grouping" "Spacing" \
  132.   ]
  133.  
  134. proc TeX::mp::latex {menu item} {
  135.     switch -- $item {
  136.     {LaTeX Help}  {set func {global HOME; edit -r [file join $HOME Help "LaTeX Help"]}}
  137.     default {set func $item}
  138.     }
  139.     eval $func
  140. }
  141.  
  142. #############################################################################
  143. #
  144. # Submenu definitions
  145. #
  146. #############################################################################
  147.  
  148. # Return the "Process" submenu.  If the current document belongs
  149. # to a TeX fileset, display the base filename throughout.
  150. #
  151. proc TeX::sub::Process {{currentWin ""}} {
  152.     global mode TeXmodeVars
  153.     if {$currentWin == ""} {set currentWin [win::Current]}
  154.     if {$currentWin == ""} {
  155.     return [TeX::sub::MinimalProcess]
  156.     } elseif { $mode == "TeX" } {
  157.     set currentDoc [file tail $currentWin]
  158.     # Process an untitled window:
  159.     if { [set num [winUntitled]] } {
  160.         if { $num > 1 } { set currentDoc "Untitled$num" }
  161.         # fall through
  162.     }
  163.     } else {
  164.     return [TeX::sub::MinimalProcess]
  165.     }
  166.     set docBasename [file rootname $currentDoc]
  167.     set projBasename $docBasename
  168.     set currentProj [isWindowInFileset $currentWin "tex"]
  169.     if {    $currentProj !=    "" } {
  170.     set currentDoc [file tail [texFilesetBaseName $currentProj]]
  171.     set docBasename [file rootname $currentDoc]
  172.     }
  173.     # Determine which menu items are dimmed:
  174.     foreach ext {DVI PS AUX IDX GLO PDF Selection} { set prefix$ext "" }
  175.     set ma [list \
  176.       {Menu -n "Format" {}} \
  177.       "(-"]
  178.     if {$TeXmodeVars(runTeXInBack)} {
  179.     lappend ma [list /TBack Typeset $currentDoc] \
  180.       [list /T<U<ITypeset $currentDoc]
  181.     } else {
  182.     lappend ma [list /TTypeset $currentDoc] \
  183.       [list /T<U<IBack Typeset $currentDoc]
  184.     }
  185.     lappend ma \
  186.       [list <U<O/V${prefixDVI}View "$docBasename\.dvi"] \
  187.       [list <U<O/P${prefixDVI}Print "$docBasename\.dvi"] \
  188.       "(-" \
  189.       {<U<O/TTypeset Clipboard} \
  190.       [list ${prefixSelection}<U<I<O/TTypeset Selection] \
  191.       "(-" \
  192.       [list <S${prefixPS}Open "$docBasename\.ps"] \
  193.       [list <S${prefixDVI}dvips "$docBasename\.dvi"] \
  194.       [list ${prefixPS}View "$docBasename\.ps"] \
  195.       [list ${prefixPS}Print "$docBasename\.ps"] \
  196.       [list ${prefixPDF}View "$docBasename\.pdf"] \
  197.       "(-" \
  198.       [list <SOpen "$docBasename\.bbl"] \
  199.       [list <S${prefixAUX}bibtex "$docBasename\.aux"] \
  200.       [list <E<SOpen "$docBasename\.ind"] \
  201.       [list <S${prefixIDX}makeindex "$docBasename\.idx"] \
  202.       [list <E<SOpen "$docBasename\.glo"] \
  203.       [list <S${prefixGLO}makeglossary "$docBasename\.glo"] \
  204.       "(-" \
  205.       {Menu -n "Open…" {}} \
  206.       "(-" \
  207.       {Remove Auxiliary Files…} \
  208.       {Remove Temporary Files}
  209.     return [list build $ma {TeX::mp::Processmenu -M TeX -m} \
  210.       {Format ProcessOpen}]
  211. }
  212.  
  213. proc TeX::sub::MinimalProcess {} {
  214.     set ma [list \
  215.       [list /TTypeset…] \
  216.       "(-" \
  217.       {<U<O/TTypeset Clipboard} \
  218.       {Typeset Selection} \
  219.       ]
  220.     return [list build $ma {TeX::mp::Processmenu -M TeX -m}]
  221. }
  222. # Return a submenu of LaTeX formats:
  223.  
  224. set "menu::proc(Format)" TeX::Format
  225. set "menu::otherflags(Format)" {-M TeX -m}
  226. set "menu::items(Format)" {
  227.     "LaTeX"
  228.     "Big-LaTeX"
  229.     "AMS-TeX"
  230.     "Plain TeX"
  231. }
  232.  
  233. # Return a submenu of LaTeX auxiliary files with basename $basename1,
  234. # except for the .aux file whose primary basename is $basename2.
  235. #
  236.  
  237. proc TeX::sub::ProcessOpen {} {
  238.     set currentWin [win::Current]
  239.     set currentDoc [file tail $currentWin]
  240.     set docBasename [file rootname $currentDoc]
  241.     set projBasename $docBasename
  242.     set currentProj [isWindowInFileset $currentWin "tex"]
  243.     if {$currentProj !=    ""} {
  244.     set currentDoc [file tail [texFilesetBaseName $currentProj]]
  245.     set docBasename [file rootname $currentDoc]
  246.     }
  247.     set ma [list \
  248.       [list "$docBasename\.log"] \
  249.       [list "<S$docBasename\.aux"] \
  250.       [list "<S$projBasename\.aux"] \
  251.       [list "$docBasename\.toc"] \
  252.       [list "$docBasename\.lof"] \
  253.       [list "$docBasename\.lot"] \
  254.       [list "$docBasename\.idx"] \
  255.       [list "$docBasename\.ind"] \
  256.       [list "$docBasename\.bbl"] \
  257.       "(-" \
  258.       [list "$docBasename\.blg"] \
  259.       [list "$docBasename\.ilg"] \
  260.       "(-" \
  261.       {<U<O/OAny TeX File…} \
  262.       ]
  263.     return [list build $ma {TeX::mp::Processmenu -M TeX -m} \
  264.       "" {Open…}]
  265.     ]
  266. }
  267. proc TeX::mp::Processmenu {submenu item} {
  268.     switch -regexp -- $item {
  269.     {Typeset Selection}  {set func "typesetSelection"}
  270.     {Typeset Clipboard}  {set func "typesetClipboard"}
  271.     "Back\ Typeset.*"    {set func "typeset 1"}
  272.     "Typeset.*"  {set func "typeset"}
  273.     "View.*\.dvi$"  {set func {doTypesetCommand view DVI}}
  274.     "Print.*\.dvi$"  {set func {doTypesetCommand print DVI}}
  275.     "dvips.*\.dvi$"  {set func {doTypesetCommand dvips DVI}}
  276.     "View.*\.ps$"  {set func {doTypesetCommand view PS}}
  277.     "View.*\.pdf$"  {set func {doTypesetCommand view PDF}}
  278.     "Print.*\.ps$"  {set func {doTypesetCommand print PS}}
  279.     "bibtex.*"  {set func {doTypesetCommand bibtex AUX}}
  280.     "makeindex.*"  {set func {doTypesetCommand makeindex IDX}}
  281.     "makeglossary.*"  {set func {doTypesetCommand makeindex GLO}}
  282.     ".*\.ps$"  {set func {doTypesetCommand open PS}}
  283.     ".*\.bbl$"  {set func {doTypesetCommand open BBL}}
  284.     ".*\.ind$"  {set func {doTypesetCommand open IND}}
  285.     ".*\.log$"  {set func {doTypesetCommand open LOG}}
  286.     ".*\.aux$"  {set func {doTypesetCommand open AUX 1}}
  287.     ".*\.aux $"  {set func {doTypesetCommand open AUX}}
  288.     ".*\.toc$"  {set func {doTypesetCommand open TOC}}
  289.     ".*\.lof$"  {set func {doTypesetCommand open LOF}}
  290.     ".*\.lot$"  {set func {doTypesetCommand open LOT}}
  291.     ".*\.idx$"  {set func {doTypesetCommand open IDX}}
  292.     ".*\.ind$"  {set func {doTypesetCommand open IND}}
  293.     ".*\.blg$"  {set func {doTypesetCommand open BLG}}
  294.     ".*\.ilg$"  {set func {doTypesetCommand open ILG}}
  295.     ".*\.glo$"  {set func {doTypesetCommand open GLO}}
  296.     {Any TeX File}  {set func "openAnyTeXFile"}
  297.     {Remove Auxiliary Files}  {set func "removeAuxiliaryFiles"}
  298.     {Remove Temporary Files}  {set func "removeTemporaryFiles"}
  299.     default {set func $item}
  300.     }
  301.     eval $func
  302. }
  303.  
  304. # Return the "Goto" submenu:
  305. set menu::proc(Goto) TeX::mp::goto
  306. set menu::otherflags(Goto) {-M TeX -m}
  307. set menu::items(Goto) {
  308.     "<U/SLaTeX"
  309.     "BibTeX"
  310.     "MakeIndex"
  311.     "(-"
  312.     {Next Template Stop}
  313.     {Prev Template Stop}
  314.     "(-"
  315.     {Next Command}
  316.     {Prev Command}
  317.     {Next Command Select}
  318.     {Prev Command Select}
  319.     {Next Command Select With Args}
  320.     {Prev Command Select With Args}
  321.     "(-"
  322.     {Next Environment}
  323.     {Prev Environment}
  324.     {Next Environment Select}
  325.     {Prev Environment Select}
  326.     "(-"
  327.     {Next Section}
  328.     {Prev Section}
  329.     {Next Section Select}
  330.     {Prev Section Select}
  331.     {Next Subsection}
  332.     {Prev Subsection}
  333.     {Next Subsection Select}
  334.     {Prev Subsection Select}
  335. }
  336.  
  337. proc TeX::mp::goto {submenu item} {
  338.     switch -- $item {
  339.     "LaTeX"  {set func "texApp TeX"}
  340.     "BibTeX" - "MakeIndex" {set func "texApp $item"}
  341.     {Next Template Stop}  {set func "ring::+"}
  342.     {Prev Template Stop}  {set func "ring::-"}
  343.     {Next Command}  {set func "nextCommand"}
  344.     {Prev Command}  {set func "prevCommand"}
  345.     {Next Command Select}  {set func "nextCommandSelect"}
  346.     {Prev Command Select}  {set func "prevCommandSelect"}
  347.     {Next Command Select With Args}  {set func "nextCommandSelectWithArgs"}
  348.     {Prev Command Select With Args}  {set func "prevCommandSelectWithArgs"}
  349.     {Next Environment}  {set func "nextEnvironment"}
  350.     {Prev Environment}  {set func "prevEnvironment"}
  351.     {Next Environment Select}  {set func "nextEnvironmentSelect"}
  352.     {Prev Environment Select}  {set func "prevEnvironmentSelect"}
  353.     {Next Section}  {set func "nextSection"}
  354.     {Prev Section}  {set func "prevSection"}
  355.     {Next Section Select}  {set func "nextSectionSelect"}
  356.     {Prev Section Select}  {set func "prevSectionSelect"}
  357.     {Next Subsection}  {set func "nextSubsection"}
  358.     {Prev Subsection}  {set func "prevSubsection"}
  359.     {Next Subsection Select}  {set func "nextSubsectionSelect"}
  360.     {Prev Subsection Select}  {set func "prevSubsectionSelect"}
  361.     default {set func $item}
  362.     }
  363.     eval $func
  364. }
  365.  
  366. # Return the "LaTeX Utilities" submenu:
  367.  
  368. set "menu::proc(LaTeX Utilities)" TeX::mp::latexUtils
  369. set "menu::otherflags(LaTeX Utilities)" {-M TeX -m}
  370. set "menu::items(LaTeX Utilities)" {
  371.     {Delete Template Stops}
  372.     {Delete Comments}
  373.     "(-"
  374.     {Convert Quotes}
  375.     {Convert Dollar Signs}
  376.     "(-"
  377.     {Short LaTeX Menu}
  378.     {AMS-LaTeX}
  379. }
  380. #        {<U<O/CChoose Command…}
  381. #        "(-"
  382.  
  383. proc TeX::mp::latexUtils {submenu item} {
  384.     switch -- $item {
  385.     {Choose Command}  {set func {chooseCommand [getLaTeXMenu]}}
  386.     {Insert Reference}  {set func "insertReference"}
  387.     {Delete Template Stops}  {set func "ring::clear"}
  388.     {Delete Comments}  {set func "deleteComments"}
  389.     {Convert Quotes}  {set func "convertQuotes"}
  390.     {Convert Dollar Signs}  {set func "convertDollarSigns"}
  391.     {Short LaTeX Menu}  {set func "toggleLaTeXMenus"}
  392.     {AMS-LaTeX}  {set func "toggleAMSLaTeX"}
  393.     default {set func "TeX::[join $item {}]"}
  394.     }
  395.     eval $func
  396. }
  397.  
  398. # Return the "Documents" submenu:
  399. set "menu::proc(Documents)" TeX::mp::documents
  400. set "menu::otherflags(Documents)" {-M TeX -m}
  401. set "menu::items(Documents)" [list \
  402.   {<U<O/NNew Document…} \
  403.   {Menu -n "Insert Document" {}} \
  404.   "(-" \
  405.   "options…" \
  406.   "<B<I/Uusepackage" \
  407.   {Menu -n "Packages" {}} \
  408.   "(-" \
  409.   "filecontents…" \
  410.   {filecontents All} \
  411.   "(-" \
  412.   {Rebuild Documents Submenu} \
  413.   ]
  414. set menu::which_subs(Documents) [list "Insert Document" "Packages"]
  415. menu::buildProc Packages TeX::sub::Packages
  416.  
  417. set "menu::proc(Insert Document)" TeX::mp::documents
  418. set "menu::otherflags(Insert Document)" {-M TeX -m}
  419. set "menu::items(Insert Document)" {
  420.     "article"
  421.     "report"
  422.     "book"
  423.     "letter"
  424.     "slides"
  425.     "other…"
  426. }
  427.  
  428.  
  429. proc TeX::mp::documents {submenu item} {
  430.     switch -- $item {
  431.     {New Document}  {set func "newLaTeXDocument"}
  432.     {article}  {set func "articleDocumentclass"}
  433.     {report}  {set func "reportDocumentclass"}
  434.     {book}  {set func "bookDocumentclass"}
  435.     {letter}  {set func "letterDocumentclass"}
  436.     {slides}  {set func "slidesDocumentclass"}
  437.     {other}  {set func "otherDocumentclass"}
  438.     {usepackage} {insertPackage ""; return}
  439.     {filecontents All} {set func "filecontentsAll"}
  440.     {Rebuild Documents Submenu}  {
  441.         global packagesSubmenuItems
  442.         set packagesSubmenuItems ""
  443.         message "Rebuilding the Documents submenu…"
  444.         menu::buildSome Documents
  445.         message ""
  446.         return
  447.     }
  448.     default {set func $item}
  449.     }
  450.     eval $func
  451. }
  452. proc TeX::sub::Packages {} {
  453.     global TeXmodeVars
  454.     if { $TeXmodeVars(buildPkgsSubmenu) } {
  455.     global packagesSubmenuItems
  456.     if { ![info exists packagesSubmenuItems] || $packagesSubmenuItems == "" } {
  457.         global latexPackages
  458.         set folders [buildTeXSearchPath 0]
  459.         set packagesSubmenuItems \
  460.           [menu::buildHierarchy $folders "Packages" TeX::mp::package latexPackages ".sty"]
  461.     }
  462.     return $packagesSubmenuItems
  463.     } else {
  464.     catch {unset packagesSubmenuItems}
  465.     return ""
  466.     }
  467. }
  468. proc TeX::mp::package {submenu pkgName} {
  469.     global latexPackages
  470.     # See latexMacros.tcl for definition of 'insertPackage':
  471.     insertPackage [file tail [file rootname $latexPackages([file join $submenu $pkgName])]]
  472. }
  473.  
  474. # Return the "Page Layout" submenu:
  475.  
  476. set "menu::otherflags(Page Layout)" {-M TeX -m}
  477. set "menu::items(Page Layout)"  {
  478.     "maketitle"
  479.     "(-"
  480.     "abstract"
  481.     "titlepage"
  482.     "(-"
  483.     "pagestyle…"
  484.     "thispagestyle…"
  485.     "pagenumbering…"
  486.     "(-"
  487.     "twocolumn"
  488.     "onecolumn"
  489. }
  490.  
  491.  
  492. # Return the "Sectioning" submenu:
  493.  
  494. set menu::proc(Sectioning) TeX::mp::sectioning
  495. set menu::otherflags(Sectioning) {-M TeX -m}
  496.  
  497. # need to integrate these two
  498. set menu::items(Sectioning) {
  499.     "<Spart"
  500.     "<S<Upart*"
  501.     "<Spart with label"
  502.     "<E<Schapter"
  503.     "<S<Uchapter*"
  504.     "<Schapter with label"
  505.     "<E<Ssection"
  506.     "<S<Usection*"
  507.     "<Ssection with label"
  508.     "<E<Ssubsection"
  509.     "<S<Usubsection*"
  510.     "<Ssubsection with label"
  511.     "<E<Ssubsubsection"
  512.     "<S<Usubsubsection*"
  513.     "<Ssubsubsection with label"
  514.     "<E<Sparagraph"
  515.     "<S<Uparagraph*"
  516.     "<Sparagraph with label"
  517.     "<E<Ssubparagraph"
  518.     "<S<Usubparagraph*"
  519.     "<Ssubparagraph with label"
  520.     "(-"
  521.     "appendix"
  522. }
  523.  
  524. proc TeX::mp::sectioning {submenu item} {
  525.     if {[regexp (part|chapter|section|paragraph) $item]} {
  526.     eval sectioning $item
  527.     } else {
  528.     eval $item
  529.     }
  530. }
  531. proc TeX::mp::sectioning {submenu item} {
  532.     if {$item == "appendix"}  {
  533.     appendix
  534.     } else {
  535.     switch -- $item {
  536.         {part with label}  {
  537.         set secName "part"
  538.         set secLabel "part."
  539.         }
  540.         {chapter with label}  {
  541.         set secName "chapter"
  542.         set secLabel "chap."
  543.         }
  544.         {section with label}  {
  545.         set secName "section"
  546.         set secLabel "sec."
  547.         }
  548.         {subsection with label}  {
  549.         set secName "subsection"
  550.         set secLabel "subsec."
  551.         }
  552.         {subsubsection with label}  {
  553.         set secName "subsubsection"
  554.         set secLabel "subsubsec."
  555.         }
  556.         {paragraph with label}  {
  557.         set secName "paragraph"
  558.         set secLabel "par."
  559.         }
  560.         {subparagraph with label}  {
  561.         set secName "subparagraph"
  562.         set secLabel "subpar."
  563.         }
  564.         default {
  565.         set secName  $item
  566.         set secLabel ""
  567.         }
  568.     }
  569.     append leftWrap [openingCarriageReturn] \
  570.       "\\${secName}\{"
  571.     if {$secLabel == ""} {
  572.         append rightWrap "\}\r"
  573.     } else {
  574.         append rightWrap "\}\\label\{" $secLabel "••\}\r"
  575.     }
  576.     #if [regexp (part|chapter) $item] {
  577.     #    append rightWrap "\\thispagestyle{empty}\r"
  578.     #}
  579.     append rightWrap "••" [closingCarriageReturn]
  580.     if {$secLabel == ""} {
  581.         if [elec::Wrap $leftWrap $rightWrap] {
  582.         message "sectioning done" 
  583.         } else { 
  584.         message "enter the $secName" 
  585.         }
  586.     } else {
  587.         if [elec::Wrap $leftWrap $rightWrap] {
  588.         message "enter the label" 
  589.         } else { 
  590.         message "enter the $secName, press <tab>, enter the label" 
  591.         }
  592.     }
  593.     }
  594. }
  595.  
  596. # Return the "Text Style" submenu:
  597. set "menu::otherflags(Text Style)" {-M TeX -m}
  598. set "menu::items(Text Style)"  {
  599.     "<S<B<I/Eemph"
  600.     "<S<U<B<I/Eem"
  601.     "<B<O/Uunderline"
  602.     "(-"
  603.     "<Supshape"
  604.     "<Stextup"
  605.     "<E<S<B<I/Itextit"
  606.     "<S<U<B<I/Iitshape"
  607.     "<E<S<B<I/Stextsl"
  608.     "<S<U<B<I/Sslshape"
  609.     "<E<S<B<I/Htextsc"
  610.     "<S<U<B<I/Hscshape"
  611.     "(-"
  612.     "<Smdseries"
  613.     "<Stextmd"
  614.     "<E<S<B<I/Btextbf"
  615.     "<S<U<B<I/Bbfseries"
  616.     "(-"
  617.     "<S<B<I/Rtextrm"
  618.     "<S<U<B<I/Rrmfamily"
  619.     "<E<S<B<I/Wtextsf"
  620.     "<S<U<B<I/Wsffamily"
  621.     "<E<S<B<I/Ytexttt"
  622.     "<S<U<B<I/Yttfamily"
  623.     "(-"
  624.     "<Snormalfont"
  625.     "<Stextnormal"
  626. }
  627.  
  628.  
  629. # Return the "Text Size" submenu:
  630. proc TeX::mp::textSize {menu item} {
  631.     doTextSize $item
  632. }
  633.  
  634. proc TeX::mp::textCommands {menu item} {
  635.     insertObject "\\${item}"
  636. }
  637. set "menu::proc(Text Commands)" TeX::mp::textCommands
  638. set "menu::otherflags(Text Commands)" {-M TeX -m}
  639. set "menu::items(Text Commands)" {
  640.     "textsuperscript"
  641.     "textcircled"
  642.     "(-"
  643.     "textcompwordmark"
  644.     "textvisiblespace"
  645.     "(-"
  646.     "!—textemdash"
  647.     "!–textendash"
  648.     "!¡textexclamdown"
  649.     "!¿textquestiondown"
  650.     "!“textquotedblleft"
  651.     "!”textquotedblright"
  652.     "!‘textquoteleft"
  653.     "!’textquoteright"
  654.     "(-"
  655.     "textbullet"
  656.     "textperiodcentered"
  657.     "(-"
  658.     "textbackslash"
  659.     "textbar"
  660.     "textless"
  661.     "textgreater"
  662.     "(-"
  663.     "textasciicircum"
  664.     "textasciitilde"
  665.     "(-"
  666.     "textregistered"
  667.     "texttrademark"
  668. }
  669.  
  670. # Return the "International" submenu:
  671. set menu::proc(International) TeX::mp::internat
  672. set menu::otherflags(International) {-M TeX -m}
  673. set menu::items(International) {
  674.     {ò}
  675.     {ó}
  676.     {ô}
  677.     {ö}
  678.     {õ}
  679.     "(-"
  680.     {ç}
  681.     {œ}
  682.     {æ}
  683.     {å}
  684.     {ø}
  685.     "(-"
  686.     {Ç}
  687.     {Œ}
  688.     {Æ}
  689.     {Å}
  690.     {Ø}
  691.     "(-"
  692.     ss
  693.     SS
  694.     "(-"
  695.     {¿}
  696.     {¡}
  697. }
  698. proc TeX::mp::internat {menu item} {
  699.     $item
  700. }
  701.  
  702. # Return the "Environments" submenu:
  703.  
  704. set menu::proc(Environments) TeX::mp::envs
  705. set menu::otherflags(Environments) {-M TeX -m}
  706. set menu::items(Environments) {
  707.     "<I/kitemize…"
  708.     "<U<I/kenumerate…"
  709.     "<B<I/kdescription…"
  710.     "thebibliography…"
  711.     "(-"
  712.     "<I/lslide"
  713.     "<U<I/loverlay"
  714.     "<B<I/lnote"
  715.     "(-"
  716.     "<I/mfigure"
  717.     "<U<I/mtable"
  718.     "<B<I/mtabular…"
  719.     "(-"
  720.     "<I/nverbatim"
  721.     "<U<I/nquote"
  722.     "<B<I/nquotation"
  723.     "verse"
  724.     "(-"
  725.     "<I/ocenter"
  726.     "<U<I/oflushleft"
  727.     "<B<I/oflushright"
  728.     "(-"
  729.     {<U<O/EChoose Environment…}
  730. }
  731. proc TeX::mp::envs {submenu item} {
  732.     switch -- $item {
  733.     {Choose Environment}  {set func chooseEnvironment}
  734.     default {set func $item}
  735.     }
  736.     eval $func
  737. }
  738.  
  739. # Return the "Boxes" submenu:
  740.  
  741. set "menu::otherflags(Boxes)" {-M TeX -m}
  742. set "menu::items(Boxes)"  {
  743.     "<B<I/Mmbox"
  744.     "makebox"
  745.     "fbox"
  746.     "framebox"
  747.     "(-"
  748.     "newsavebox"
  749.     "sbox"
  750.     "savebox"
  751.     "usebox"
  752.     "(-"
  753.     "raisebox"
  754.     "(-"
  755.     "parbox"
  756.     "minipage"
  757.     "(-"
  758.     "rule"
  759. }
  760.  
  761. # Return the "Miscellaneous" submenu:
  762. set menu::proc(Miscellaneous) TeX::mp::misc
  763. set menu::otherflags(Miscellaneous) {-M TeX -m}
  764. set menu::items(Miscellaneous) {
  765.     "<B<I/Vverb"
  766.     "<B<I/Ffootnote"
  767.     {<B<I/Nmarginal note}
  768.     "(-"
  769.     "<B<I/Llabel"
  770.     "<B<I/Xref"
  771.     "eqref"
  772.     "<B<I/Ppageref"
  773.     "<B<I/Ccite"
  774.     "<U<B<I/Cnocite"
  775.     "(-"
  776.     "<B<I/Jitem"
  777.     "(-"
  778.     "<B<I/'quotes"
  779.     {<U<B<I/'double quotes}
  780.     "(-"
  781.     {TeX logo}
  782.     {LaTeX logo}
  783.     {LaTeX2e logo}
  784.     "date"
  785.     "(-"
  786.     "!†dag"
  787.     "ddag"
  788.     {!§section mark}
  789.     {!¶paragraph mark}
  790.     "!©copyright"
  791.     "!£pounds"
  792. }
  793. proc TeX::mp::misc {submenu item} {
  794.     switch -- $item {
  795.     {marginal note}  {set func "marginalNote"}
  796.     "item" {set func "insertItem"}
  797.     "label" {set func "insertLabel"}
  798.     {double quotes}  {set func "dblQuotes"}
  799.     {TeX logo}  {set func "texLogo"}
  800.     {LaTeX logo}  {set func "latexLogo"}
  801.     {LaTeX2e logo}  {set func "latex2eLogo"}
  802.     "date" {set func "today"}
  803.     {section mark}  {set func "sectionMark"}
  804.     {paragraph mark}  {set func "paragraphMark"}
  805.     default {set func $item}
  806.     }
  807.     eval $func
  808. }
  809.  
  810. # Return a "Math Modes" submenu (called below and in latexKeys.tcl):
  811. set "menu::proc(Math Modes)" TeX::mp::mathModes
  812. set "menu::otherflags(Math Modes)" {-M TeX -m}
  813. proc TeX::sub::MathModes {} {
  814.     global TeXmodeVars menu::items
  815.     if {$TeXmodeVars(useDollarSigns)} {
  816.     Bind '4' <zc> texMath "TeX"
  817.     Bind '4' <zoc> texDisplaymath "TeX"
  818.     set "menu::items(Math Modes)" {
  819.         {<B<O/MTeX math}
  820.         {<B<I<O/MTeX displaymath}
  821.         "(-"
  822.         {LaTeX math}
  823.         {LaTeX displaymath}
  824.     }
  825.     } else {
  826.     Bind '4' <zc> latexMath "TeX"
  827.     Bind '4' <zoc> latexDisplaymath "TeX"
  828.     set "menu::items(Math Modes)" {
  829.         {TeX math}
  830.         {TeX displaymath}
  831.         "(-"
  832.         {<B<O/MLaTeX math}
  833.         {<B<I<O/MLaTeX displaymath}
  834.     }
  835.     }
  836. }
  837. proc TeX::mp::mathModes {submenu item} {
  838.     switch -- $item {
  839.     {TeX math}  {set func "texMath"}
  840.     {TeX displaymath}  {set func "texDisplaymath"}
  841.     {LaTeX math}  {set func "latexMath"}
  842.     {LaTeX displaymath}  {set func "latexDisplaymath"}
  843.     default {set func $item}
  844.     }
  845.     eval $func
  846. }
  847.  
  848. proc TeX::mp::mathStyle {submenu item} {
  849.     switch -- $item {
  850.     mathbb {doUppercaseMathStyle mathbb "math blackboard bold"}
  851.     mathfrak {doMathStyle mathfrak "math fraktur"}
  852.     mathit {doMathStyle mathit "math italic"}
  853.     mathrm {doMathStyle mathrm "math roman"}
  854.     mathbf {doMathStyle mathbf "math bold"}
  855.     mathsf {doMathStyle mathsf "math sans serif"}
  856.     mathtt {doMathStyle mathtt "math typewriter"}
  857.     mathcal {doUppercaseMathStyle mathcal "math calligraphic"}
  858.     displaystyle {doMathStyle displaystyle "display style"}
  859.     textstyle {doMathStyle textstyle "text style"}
  860.     scriptstyle {doMathStyle scriptstyle "script style"}
  861.     scriptscriptstyle {doMathStyle scriptscriptstyle "scriptscript style"}
  862.     }
  863. }
  864.  
  865. # Return the "Math Style" submenu:
  866. set "menu::proc(Math Style)" TeX::mp::mathStyle
  867. set "menu::otherflags(Math Style)" {-M TeX -m}
  868. set "menu::proc(Text Size)" TeX::mp::textSize
  869. set "menu::otherflags(Text Size)" {-M TeX -m}
  870. proc toggleAMSLaTeXmenus {} {
  871.     global useAMSLaTeX menu::items
  872.     if { $useAMSLaTeX } {
  873.     set "menu::items(Math Style)" {
  874.         "<B<I<O/Imathit"
  875.         "<B<I<O/Rmathrm"
  876.         "<B<I<O/Bmathbf"
  877.         "<B<I<O/Wmathsf"
  878.         "<B<I<O/Ymathtt"
  879.         "<B<I<O/Cmathcal"
  880.         "(-"
  881.         "<B<I<O/Zmathbb"
  882.         "mathfrak"
  883.         "(-"
  884.         "<B<I<O/Ddisplaystyle"
  885.         "<B<I<O/Ttextstyle"
  886.         "<B<I<O/Sscriptstyle"
  887.         "scriptscriptstyle"
  888.     }
  889.     set "menu::items(Text Size)" {
  890.         "<B<I/1Tiny"
  891.         "<B<I/2tiny"
  892.         "<B<I/3SMALL"
  893.         "<B<I/4Small"
  894.         "<B<I/5small"
  895.         "normalsize"
  896.         "<B<I/6large"
  897.         "<B<I/7Large"
  898.         "<B<I/8LARGE"
  899.         "<B<I/9huge"
  900.         "<B<I/0Huge"
  901.     }
  902.     set "menu::items(Math Environments)" {
  903.         "<I/imath"
  904.         "(-"
  905.         "<S<B/iequation*"
  906.         "<S<I<B/iequation"
  907.         "subequations"
  908.         "(-"
  909.         "<S<B/jalign*…"
  910.         "<S<B<I/jalign…"
  911.         "<E<Sflalign…"
  912.         "<Sflalign*…"
  913.         "<E<Salignat…"
  914.         "<Salignat*…"
  915.         "<E<S<U/jgather*…"
  916.         "<S<I<U/jgather…"
  917.         "<E<S<B<U/jmultline*…"
  918.         "<S<I<B<U/jmultline…"
  919.         "(-"
  920.         "gathered…"
  921.         "aligned…"
  922.         "alignedat…"
  923.         "split…"
  924.         "cases…"
  925.         "(-"
  926.         "array…"
  927.         "subarray…"
  928.         "matrix…"
  929.         "pmatrix…"
  930.         "bmatrix…"
  931.         "Bmatrix…"
  932.         "vmatrix…"
  933.         "Vmatrix…"
  934.         "smallmatrix…"
  935.         "(-"
  936.         {<U<O/EChoose Environment…}
  937.     }
  938.     } else {
  939.     set "menu::items(Math Style)" {
  940.         "<B<I<O/Imathit"
  941.         "<B<I<O/Rmathrm"
  942.         "<B<I<O/Bmathbf"
  943.         "<B<I<O/Wmathsf"
  944.         "<B<I<O/Ymathtt"
  945.         "<B<I<O/Cmathcal"
  946.         "(-"
  947.         "<B<I<O/Ddisplaystyle"
  948.         "<B<I<O/Ttextstyle"
  949.         "<B<I<O/Sscriptstyle"
  950.         "scriptscriptstyle"
  951.     }
  952.     set "menu::items(Text Size)" {
  953.         "<B<I/1tiny"
  954.         "<B<I/2scriptsize"
  955.         "<B<I/3footnotesize"
  956.         "<B<I/4small"
  957.         "<B<I/5normalsize"
  958.         "<B<I/6large"
  959.         "<B<I/7Large"
  960.         "<B<I/8LARGE"
  961.         "<B<I/9huge"
  962.         "<B<I/0Huge"
  963.     }
  964.     set "menu::items(Math Environments)" {
  965.         "<I/imath"
  966.         "(-"
  967.         "<U<I/idisplaymath"
  968.         "<B<I/iequation"
  969.         "(-"
  970.         "<B<I/jeqnarray…"
  971.         "<U<I/jeqnarray*…"
  972.         "(-"
  973.         "<I/jarray…"
  974.         "(-"
  975.         {<U<O/EChoose Environment…}
  976.     }
  977.     }
  978. }
  979.  
  980. # Return the "Math Environments" submenu:
  981. set "menu::proc(Math Environments)" TeX::mp::mathEnvs
  982. set "menu::otherflags(Math Environments)" {-M TeX -m}
  983. proc TeX::mp::mathEnvs {submenu item} {
  984.     switch -- $item {
  985.     "multline" - "multline\*" - "gather" - "gather\*" - \
  986.       "align" -  "align\*" - "flalign" - "flalign\*" - "alignat" - "alignat\*" - \
  987.       "array" - \
  988.       "eqnarray\*" - "eqnarray" - \
  989.       "split" - "aligned" - "gathered" - "alignedat" - "cases" - \
  990.       "matrix" - "pmatrix" - "bmatrix" - "Bmatrix" - "vmatrix" - "Vmatrix" - \
  991.       "smallmatrix" {
  992.         set func "TeXmathenv $item"
  993.     }
  994.     "equation" {
  995.         set func "mathEnvironment $item"
  996.     }
  997.     {Choose Environment}  {set func chooseEnvironment}
  998.     default {set func $item}
  999.     }
  1000.     eval $func
  1001. }
  1002.  
  1003. #--------------------------------------------------------------------------
  1004. # Adding a "Theorem" submenu: many thanks to...
  1005. #
  1006. # Paul Gastin
  1007. # LIAFA
  1008. # Universite Paris 7
  1009. # 2, place Jussieu
  1010. # F-75251 Paris Cedex 05
  1011. # email : Paul.Gastin@liafa.jussieu.fr
  1012. # www : http://www.liafa.jussieu.fr/~gastin
  1013. #--------------------------------------------------------------------------
  1014.  
  1015. # Return the "Theorem" submenu:
  1016. set menu::proc(Theorem) TeX::mp::theorem
  1017. set menu::otherflags(Theorem) {-M TeX -m}
  1018. set menu::items(Theorem) {
  1019.     "<E<Sdefinition"
  1020.     "<Sdefinition with label"
  1021.     "<E<Sremark"
  1022.     "<Sremark with label"
  1023.     "(-"
  1024.     "<E<Slemma"
  1025.     "<Slemma with label"
  1026.     "<E<Sproposition"
  1027.     "<Sproposition with label"
  1028.     "<E<Stheorem"
  1029.     "<Stheorem with label"
  1030.     "<E<Scorollary"
  1031.     "<Scorollary with label"
  1032.     "(-"
  1033.     "claim"
  1034.     "<E<Sclaimno"
  1035.     "<Sclaimno with label"
  1036.     "(-"
  1037.     "proof"
  1038.     "proofof"
  1039. }
  1040.  
  1041. proc TeX::mp::theorem {submenu item} {
  1042.     if {$item == "proofof"} {
  1043.     if {[wrapStructure "\\begin\{proofof\}\{••\}" "" \
  1044.       "\\end\{proofof\}\r••"] } {
  1045.         set msgText "selection wrapped, enter ref of proofof environment"
  1046.     } else {
  1047.         set msgText "enter ref of proofof environment, press <tab>, enter the body of proofof environment"
  1048.     }
  1049.     } else {
  1050.     switch -- $item {
  1051.         {definition with label}  {
  1052.         set envName "definition"
  1053.         set envLabel "def[TeX::labelDelim]"
  1054.         }
  1055.         {remark with label}  {
  1056.         set envName "remark"
  1057.         set envLabel "rem[TeX::labelDelim]"
  1058.         }
  1059.         {lemma with label}  {
  1060.         set envName "lemma"
  1061.         set envLabel "lem[TeX::labelDelim]"
  1062.         }
  1063.         {proposition with label}  {
  1064.         set envName "proposition"
  1065.         set envLabel "prop[TeX::labelDelim]"
  1066.         }
  1067.         {theorem with label}  {
  1068.         set envName "theorem"
  1069.         set envLabel "thm[TeX::labelDelim]"
  1070.         }
  1071.         {corollary with label}  {
  1072.         set envName "corollary"
  1073.         set envLabel "cor[TeX::labelDelim]"
  1074.         }
  1075.         {claimno with label}  {
  1076.         set envName "claimno"
  1077.         set envLabel "claim[TeX::labelDelim]"
  1078.         }
  1079.         default {
  1080.         set envName  $item
  1081.         set envLabel ""
  1082.         }
  1083.     }
  1084.     if {$envLabel == ""} {
  1085.         append begStruct "\\begin\{" $envName "\}"
  1086.         append endStruct "\\end\{" $envName "\}\r••"
  1087.         if {[wrapStructure $begStruct "" $endStruct]} {
  1088.         set msgText "selection wrapped"
  1089.         } else {
  1090.         set msgText "enter the body of $envName environment"
  1091.         }
  1092.     } else {
  1093.         append begStruct "\\begin\{" $envName "\}\\label\{" $envLabel "••\}"
  1094.         append endStruct "\\end\{" $envName "\}\r••"
  1095.         if {[wrapStructure $begStruct "" $endStruct]} {
  1096.         set msgText "selection wrapped, enter the label"
  1097.         } else {
  1098.         set msgText "enter the label, press <tab>, enter the body of $envName environment"
  1099.         }
  1100.     }
  1101.     }
  1102.     message $msgText
  1103. }
  1104.  
  1105. # Return the "Formulas" submenu:
  1106. set menu::proc(Formulas) TeX::mp::formulas
  1107. set menu::otherflags(Formulas) {-M TeX -m}
  1108. set menu::items(Formulas) {
  1109.     "subscript"
  1110.     "superscript"
  1111.     "(-"
  1112.     "<B<O/Ffrac"
  1113.     {<B<O/Rsqrt}
  1114.     {nth root}
  1115.     "(-"
  1116.     {<B<O/1one parameter…}
  1117.     {<B<O/2two parameters…}
  1118. }
  1119. proc TeX::mp::formulas {submenu item} {
  1120.     switch -- $item {
  1121.     {frac}  {set func "fraction"}
  1122.     {sqrt}  {set func "squareRoot"}
  1123.     {nth root}  {set func "nthRoot"}
  1124.     {one parameter}  {set func "oneParameter"}
  1125.     {two parameters}  {set func "twoParameters"}
  1126.     default {set func $item}
  1127.     }
  1128.     eval $func
  1129. }
  1130.  
  1131. proc TeX::mp::greek {submenu item} {
  1132.     checkMathMode $item 1; insertObject "\\$item"
  1133. }
  1134.  
  1135. # Return the "Greek" submenu:
  1136. set menu::proc(Greek) TeX::mp::greek
  1137. set menu::otherflags(Greek) {-M TeX -m}
  1138. set menu::items(Greek) {
  1139.     "alpha"
  1140.     "beta"
  1141.     "<SGamma"
  1142.     "<Sgamma"
  1143.     "<E<SDelta"
  1144.     "<Sdelta"
  1145.     "epsilon"
  1146.     "zeta"
  1147.     "eta"
  1148.     "<STheta"
  1149.     "<Stheta"
  1150.     "iota"
  1151.     "kappa"
  1152.     "<SLambda"
  1153.     "<Slambda"
  1154.     "mu"
  1155.     "nu"
  1156.     "<SXi"
  1157.     "<Sxi"
  1158.     "omicron"
  1159.     "<SPi"
  1160.     "<Spi"
  1161.     "rho"
  1162.     "<SSigma"
  1163.     "<Ssigma"
  1164.     "tau"
  1165.     "<SUpsilon"
  1166.     "<Supsilon"
  1167.     "<E<SPhi"
  1168.     "<Sphi"
  1169.     "chi"
  1170.     "<SPsi"
  1171.     "<Spsi"
  1172.     "<E<SOmega"
  1173.     "<Somega"
  1174.     "(-"
  1175.     "varepsilon"
  1176.     "vartheta"
  1177.     "varpi"
  1178.     "varrho"
  1179.     "varsigma"
  1180.     "varphi"
  1181. }
  1182.  
  1183. proc TeX::mp::binaryOperators {submenu item} {
  1184.     regsub "!." $item "" item
  1185.     if {[regexp {[lr]hd$} $item]} {
  1186.     if {![TeX::RequirePackage latexsym]} {return}
  1187.     }
  1188.     checkMathMode $item 1; insertObject "\\$item"
  1189. }
  1190.  
  1191. # Return the "Binary Operators" submenu:
  1192. set "menu::proc(Binary Operators)" TeX::mp::binaryOperators
  1193. set "menu::otherflags(Binary Operators)" {-M TeX -m}
  1194. set "menu::items(Binary Operators)" {
  1195.     "/+<I<U!±pm"
  1196.     "mp"
  1197.     "times"
  1198.     "!÷div"
  1199.     "ast"
  1200.     "star"
  1201.     "circ"
  1202.     "bullet"
  1203.     "cdot"
  1204.     "cap"
  1205.     "cup"
  1206.     "uplus"
  1207.     "sqcap"
  1208.     "sqcup"
  1209.     "vee"
  1210.     "wedge"
  1211.     "setminus"
  1212.     "(-"
  1213.     "diamond"
  1214.     "bigtriangleup"
  1215.     "bigtriangledown"
  1216.     "triangleleft"
  1217.     "triangleright"
  1218.     "lhd"
  1219.     "rhd"
  1220.     "unlhd"
  1221.     "unrhd"
  1222.     "(-"
  1223.     "oplus"
  1224.     "ominus"
  1225.     "otimes"
  1226.     "oslash"
  1227.     "odot"
  1228.     "(-"
  1229.     "bigcirc"
  1230.     "dagger"
  1231.     "ddagger"
  1232.     "amalg"
  1233.     "wr"
  1234. }
  1235.  
  1236. # Return the "Relations" submenu:
  1237. set menu::proc(Relations) TeX::mp::relations
  1238. set menu::otherflags(Relations) {-M TeX -m}
  1239. set menu::items(Relations) {
  1240.     "<S!≥geq"
  1241.     "<S!≤leq"
  1242.     "<E<Ssucc"
  1243.     "<Sprec"
  1244.     "<E<Ssucceq"
  1245.     "<Spreceq"
  1246.     "<E<S!»gg"
  1247.     "<S!«ll"
  1248.     "<E<Ssupset"
  1249.     "<Ssubset"
  1250.     "<E<Ssupseteq"
  1251.     "<Ssubseteq"
  1252.     "<E<Ssqsupset"
  1253.     "<Ssqsubset"
  1254.     "<E<Ssqsupseteq"
  1255.     "<Ssqsubseteq"
  1256.     "<E<Sni"
  1257.     "<Sin"
  1258.     "<E<Sdashv"
  1259.     "<Svdash"
  1260.     "(-"
  1261.     "equiv"
  1262.     "sim"
  1263.     "simeq"
  1264.     "asymp"
  1265.     "!≈approx"
  1266.     "cong"
  1267.     "/=<I!≠neq"
  1268.     "doteq"
  1269.     "propto"
  1270.     "(-"
  1271.     "models"
  1272.     "perp"
  1273.     "mid"
  1274.     "parallel"
  1275.     "bowtie"
  1276.     "join"
  1277.     "smile"
  1278.     "frown"
  1279. }
  1280. proc TeX::mp::relations {submenu item} {
  1281.     # workaround alpha menu bug
  1282.     regsub "!." $item "" item
  1283.     if {[lsearch -exact "join sqsubset sqsupset" $item] != -1} {
  1284.     if {![TeX::RequirePackage latexsym]} {return}
  1285.     }
  1286.     checkMathMode $item 1; insertObject "\\$item"
  1287. }
  1288.  
  1289. # Return the "Arrows" submenu:
  1290. set menu::otherflags(Arrows) {-M TeX -m}
  1291. set menu::proc(Arrows) TeX::mp::arrows
  1292. set menu::items(Arrows) {
  1293.     "<SLeftarrow"
  1294.     "<Sleftarrow"
  1295.     "<E<SRightarrow"
  1296.     "<Srightarrow"
  1297.     "<E<SLeftrightarrow"
  1298.     "<Sleftrightarrow"
  1299.     "<E<SLongleftarrow"
  1300.     "<Slongleftarrow"
  1301.     "<E<SLongrightarrow"
  1302.     "<Slongrightarrow"
  1303.     "<E<SLongleftrightarrow"
  1304.     "<Slongleftrightarrow"
  1305.     "(-"
  1306.     "<SUparrow"
  1307.     "<Suparrow"
  1308.     "<E<SDownarrow"
  1309.     "<Sdownarrow"
  1310.     "<E<SUpdownarrow"
  1311.     "<Supdownarrow"
  1312.     "(-"
  1313.     "mapsto"
  1314.     "longmapsto"
  1315.     "leadsto"
  1316.     "(-"
  1317.     "leftharpoonup"
  1318.     "rightharpoonup"
  1319.     "leftharpoondown"
  1320.     "rightharpoondown"
  1321.     "rightleftharpoons"
  1322.     "hookleftarrow"
  1323.     "hookrightarrow"
  1324.     "nearrow"
  1325.     "searrow"
  1326.     "swarrow"
  1327.     "nwarrow"
  1328. }
  1329.  
  1330. proc TeX::mp::arrows {submenu item} {
  1331.     checkMathMode $item 1; insertObject "\\$item"
  1332. }
  1333.  
  1334. # Return the "Dots" submenu:
  1335. set menu::proc(Dots) TeX::mp::generalMath
  1336. set menu::otherflags(Dots) {-M TeX -m}
  1337. set menu::items(Dots) {
  1338.     "bullet"
  1339.     "cdot"
  1340.     "(-"
  1341.     "ldots"
  1342.     "cdots"
  1343.     "vdots"
  1344.     "ddots"
  1345. }
  1346.  
  1347. # Return the "Symbols" submenu:
  1348. set menu::proc(Symbols) TeX::mp::generalMath
  1349. set menu::otherflags(Symbols) {-M TeX -m}
  1350. set menu::items(Symbols) {
  1351.     "aleph"
  1352.     "hbar"
  1353.     "imath"
  1354.     "jmath"
  1355.     "ell"
  1356.     "wp"
  1357.     "Re"
  1358.     "Im"
  1359.     "mho"
  1360.     "(-"
  1361.     "angle"
  1362.     "backslash"
  1363.     "bot"
  1364.     "/0<Iemptyset"
  1365.     "exists"
  1366.     "forall"
  1367.     "!∞infty"
  1368.     "nabla"
  1369.     "!¬neg"
  1370.     "!∂partial"
  1371.     "prime"
  1372.     "!√surd"
  1373.     "top"
  1374.     "(-"
  1375.     "Box"
  1376.     "Diamond"
  1377.     "triangle"
  1378.     "clubsuit"
  1379.     "diamondsuit"
  1380.     "heartsuit"
  1381.     "spadesuit"
  1382.     "(-"
  1383.     "flat"
  1384.     "natural"
  1385.     "sharp"
  1386. }
  1387.  
  1388. proc TeX::mp::generalMath {submenu item} {
  1389.     if {[lsearch -exact "mho Box Diamond" $item] != -1} {
  1390.     if {![TeX::RequirePackage latexsym]} {return}
  1391.     }
  1392.     switch -- $item {
  1393.     "lim" - "inf" - "liminf" - "limsup" - "max" - "min" - "sup" {
  1394.         checkMathMode $item 1
  1395.         if {[elec::Wrap "\\${item}_{" "}••"]} {
  1396.         message "limit set"
  1397.         } else {
  1398.         message "enter limit"
  1399.         }
  1400.     }
  1401.     "pmod" {
  1402.         checkMathMode "pmod" 1
  1403.         if {[elec::Wrap "\\pmod{" "}••"]} {
  1404.         message "parenthesized mod set"
  1405.         } else {
  1406.         message "enter formula"
  1407.         }
  1408.     }
  1409.     "ldots" {insertObject "\\ldots"}
  1410.     default {
  1411.         checkMathMode $item 1; insertObject "\\$item"
  1412.     }
  1413.     }
  1414. }
  1415.  
  1416. # Return the "Functions" submenu:
  1417. set menu::proc(Functions) TeX::mp::generalMath
  1418. set menu::otherflags(Functions) {-M TeX -m}
  1419. set menu::items(Functions) {
  1420.     "arccos"
  1421.     "arcsin"
  1422.     "arctan"
  1423.     "arg"
  1424.     "cos"
  1425.     "cosh"
  1426.     "cot"
  1427.     "coth"
  1428.     "csc"
  1429.     "deg"
  1430.     "det"
  1431.     "dim"
  1432.     "exp"
  1433.     "gcd"
  1434.     "hom"
  1435.     "inf"
  1436.     "ker"
  1437.     "lg"
  1438.     "<B<O/Llim"
  1439.     "liminf"
  1440.     "limsup"
  1441.     "ln"
  1442.     "log"
  1443.     "max"
  1444.     "min"
  1445.     "Pr"
  1446.     "sec"
  1447.     "sin"
  1448.     "sinh"
  1449.     "sup"
  1450.     "tan"
  1451.     "tanh"
  1452.     "(-"
  1453.     "bmod"
  1454.     "pmod"
  1455. }
  1456.  
  1457. # Return the "Large Operators" submenu:
  1458. set "menu::otherflags(Large Operators)" {-M TeX -m}
  1459. set "menu::items(Large Operators)"  {
  1460.     "<B<O/Ssum"
  1461.     "<B<O/Pprod"
  1462.     "coprod"
  1463.     "<B<O/Iint"
  1464.     "oint"
  1465.     "(-"
  1466.     "bigcup"
  1467.     "bigcap"
  1468.     "bigsqcup"
  1469.     "bigvee"
  1470.     "bigwedge"
  1471.     "bigodot"
  1472.     "bigotimes"
  1473.     "bigoplus"
  1474.     "biguplus"
  1475. }
  1476.  
  1477. # Return the "Delimiters" submenu:
  1478. set menu::proc(Delimiters) TeX::mp::delimiters
  1479. set menu::otherflags(Delimiters) {-M TeX -m}
  1480. set menu::items(Delimiters) {
  1481.     "parentheses"
  1482.     "brackets"
  1483.     "braces"
  1484.     {vertical bars}
  1485.     {other delims…}
  1486.     "(-"
  1487.     {half-open interval}
  1488.     {half-closed interval}
  1489.     "(-"
  1490.     {<Smulti-line big parentheses}
  1491.     {<Sbig parentheses}
  1492.     {<E<Smulti-line big brackets}
  1493.     {<Sbig brackets}
  1494.     {<E<Smulti-line big braces}
  1495.     {<Sbig braces}
  1496.     {<E<Smulti-line big vertical bars}
  1497.     {<Sbig vertical bars}
  1498.     {<E<Sother multi-line big delims…}
  1499.     {<Sother big delims…}
  1500.     "(-"
  1501.     {<Smulti-line big left brace}
  1502.     {<Sbig left brace}
  1503.     {<E<Sother multi-line mixed big delims…}
  1504.     {<Sother mixed big delims…}
  1505. }
  1506. proc TeX::mp::delimiters {submenu item} {
  1507.     switch -- $item {
  1508.     {vertical bars}  {set func "absoluteValue"}
  1509.     {other delims}  {set func "otherDelims"}
  1510.     {half-open interval}  {set func "half-openInterval"}
  1511.     {half-closed interval}  {set func "half-closedInterval"}
  1512.     {big parentheses}  {set func "bigParens"}
  1513.     {multi-line big parentheses}  {set func "multiBigParens"}
  1514.     {big brackets}  {set func "bigBrackets"}
  1515.     {multi-line big brackets}  {set func "multiBigBrackets"}
  1516.     {big braces}  {set func "bigBraces"}
  1517.     {multi-line big braces}  {set func "multiBigBraces"}
  1518.     {big vertical bars}  {set func "bigAbsValue"}
  1519.     {multi-line big vertical bars}  {set func "multiBigAbsValue"}
  1520.     {other big delims}  {set func "otherBigDelims"}
  1521.     {other multi-line big delims}  {set func "otherMultiBigDelims"}
  1522.     {big left brace}  {set func "bigLeftBrace"}
  1523.     {multi-line big left brace}  {set func "multiBigLeftBrace"}
  1524.     {other mixed big delims}  {set func "otherMixedBigDelims"}
  1525.     {other multi-line mixed big delims}  {set func "otherMultiMixedBigDelims"}
  1526.     default {set func $item}
  1527.     }
  1528.     eval $func
  1529. }
  1530.  
  1531. # Return the "Math Accents" submenu:
  1532. set "menu::otherflags(Math Accents)" {-M TeX -m}
  1533. set "menu::items(Math Accents)"  {
  1534.     "<B<O/Aacute"
  1535.     "<B<O/Bbar"
  1536.     "breve"
  1537.     "<B<O/Ccheck"
  1538.     "<B<O/Ddot"
  1539.     "ddot"
  1540.     "<B<O/Ggrave"
  1541.     "<B<O/Hhat"
  1542.     "<B<O/Ttilde"
  1543.     "<B<O/Vvec"
  1544.     "(-"
  1545.     "widehat"
  1546.     "widetilde"
  1547.     "(-"
  1548.     "imath"
  1549.     "jmath"
  1550. }
  1551.  
  1552. # Return the "Grouping" submenu:
  1553. set "menu::otherflags(Grouping)" {-M TeX -m}
  1554. set "menu::items(Grouping)"  {
  1555.     "<B<O/Uunderline"
  1556.     "<B<O/Ooverline"
  1557.     "<B<I<O/Uunderbrace"
  1558.     "<B<I<O/Ooverbrace"
  1559.     "(-"
  1560.     "overrightarrow"
  1561.     "overleftarrow"
  1562.     "(-"
  1563.     "stackrel"
  1564. }
  1565.  
  1566. # Return the "Spacing" submenu:
  1567. set menu::proc(Spacing) TeX::mp::spacing
  1568. set menu::otherflags(Spacing) {-M TeX -m}
  1569. set menu::items(Spacing) {
  1570.     {neg thin}
  1571.     "thin"
  1572.     "medium"
  1573.     "thick"
  1574.     "(-"
  1575.     "quad"
  1576.     "qquad"
  1577.     "(-"
  1578.     "hspace"
  1579.     "vspace"
  1580.     "(-"
  1581.     "hfill"
  1582.     "vfill"
  1583.     "(-"
  1584.     "smallskip"
  1585.     "medskip"
  1586.     "bigskip"
  1587. }
  1588. proc TeX::mp::spacing {submenu item} {
  1589.     switch -- $item {
  1590.     {neg thin}  {set func "negThin"}
  1591.     default {set func $item}
  1592.     }
  1593.     eval $func
  1594. }
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.